<script setup lang="ts">
import RePlayer from "@/components/RePlayer/src/index.vue";
import { FormProps } from "@/views/learn/chapters/utils/types";

import { ref } from "vue";
import type { TabsPaneContext } from "element-plus";
import Comment from "@/views/learn/chapters/comment.vue";
import ReCol from "@/components/ReCol";

const activeName = ref("first");

const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event);
};

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: null,
    title: "",
    courseId: null,
    content: "",
    video: "",
    rank: 0,
    fileList: []
  })
});
</script>

<template>
  <div>
    <el-row :gutter="24">
      <re-col :value="12" :md="24" :sm="12" :xs="24">
        <RePlayer
          :id="'video' + formInline.id"
          :width="'100%'"
          :height="500"
          :url="formInline.video"
          style="border-radius: 10px"
          :controls="true"
        />
      </re-col>
      <re-col :value="12" :md="24" :sm="12" :xs="24">
        <el-tabs
          v-model="activeName"
          class="demo-tabs md:mt-8 xl:mt-0"
          @tab-click="handleClick"
        >
          <el-tab-pane label="简介" name="first">
            <div class="brief text-sm indent-6" v-html="formInline.content" />
          </el-tab-pane>
          <el-tab-pane label="评论" name="second" style="overflow: auto">
            <div style="height: 440px; overflow: auto">
              <Comment :chapterId="formInline.id" />
            </div>
          </el-tab-pane>
        </el-tabs>
      </re-col>
    </el-row>
  </div>
</template>
<style lang="scss" scoped>
/* 隐藏滚动条 */
::-webkit-scrollbar-track {
  background-color: transparent;
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* 选项卡 */
:deep(.demo-tabs) {
  .brief {
    max-height: 400px;
    padding: 15px 10px;
    overflow: auto;
    background-color: var(--u-bg-color-secondary);
    border-radius: 5px;
  }

  .el-tabs__content {
    padding: 10px;
  }

  .el-tabs__item {
    font-size: 17px;
    font-weight: bold;
  }

  .el-tabs__header {
    margin-bottom: 0;
  }

  .el-tabs__nav-scroll {
    padding: 0 10px;
  }

  .el-tabs__nav-wrap::after {
    width: 0;
  }

  /* 评论 */
  .u-comment {
    padding: 0;

    .comment-form {
      padding: 0;
    }
  }
}
</style>
